<template>
  <div class="outer">
    <header class="shadow p-3">
     <div class="container">
       <div class="row">
         <div class="col-8">
           <h1>
             <router-link to="/index">{{company}}预算智能管理平台</router-link>
           </h1>
         </div>
         <div class="col-4 text-right">
           <el-dropdown style="margin-top: 4%">
              <span class="el-dropdown-link text-white" style="display: block;">
                设置<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
             <el-dropdown-menu slot="dropdown">
               <el-dropdown-item @click.native="goCompany">切换公司</el-dropdown-item>
               <el-dropdown-item @click.native="goDataList">数据管理</el-dropdown-item>
               <el-dropdown-item @click.native="goOut">退出登录</el-dropdown-item>
<!--               <el-dropdown-item @click.native="fixedPassworld">修改密码</el-dropdown-item>-->
             </el-dropdown-menu>
           </el-dropdown>
         </div>
       </div>
     </div>
    </header>
    <div class="container-fluid pl-0 pr-0" style="height: 100%; ">
      <div class="center" >
        <keep-alive>
         <router-view v-if="$route.meta.KeepAlive"></router-view>
        </keep-alive>
        <router-view v-if="!$route.meta.KeepAlive"></router-view>
      </div>
    </div>
    <el-dialog title="修改密码" :visible.sync="dialogFormVisible" width="40%">
      <el-form :model="form" class="ml-4 mr-4">
        <el-form-item label="旧密码" :label-width="formLabelWidth">
          <el-input type="password" v-model="form.oldPass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="新密码" :label-width="formLabelWidth">
          <el-input type="password" v-model="form.newPass" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="fixedPass">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
    export default {
      name: "index",
      data(){
        return {
          dialogFormVisible:false,
          company: window.sessionStorage.getItem('company'),
          orgid: window.sessionStorage.getItem('orgid'),
          isBoss: window.sessionStorage.getItem('isBoss'),
          form:{
            oldPass: '',
            newPass:''
          },
          formLabelWidth: '120px'
        }
      },
      methods: {
        goCompany () {
          this.$router.push('/company')
        },
        goOut(){
          window.sessionStorage.clear()
          this.$router.push('/login')
        },
        goDataList(){
          this.$router.push('/dataList')
        },
        fixedPassworld(){
          this.dialogFormVisible = true;
          this.form = {
            oldPass: '',
            newPass:''
          }
        },
        fixedPass() {
          this.$http.post(
            '/api/edit/password',
            {
              orgid: this.orgid,
              password: this.form.oldPass,
              newPassword: this.form.newPass
            }, {
              emulateJSON:true
            }).then(res => {
            if(res.data.code==500){
              this.$message({
                type: "error",
                message: res.data.data
              })
            }else{
              this.dialogFormVisible = false;
              this.$message({
                type: "success",
                message: res.data.data
              })
              this.$router.push("/login");
              window.sessionStorage.clear()
            }
          })
        }
      }
    }
</script>

<style scoped>
  .outer{
    height: 100%;
  }
 header{
   background-image: linear-gradient(to right, #005bea ,#00c6fb);
   /*background: url("~@/assets/img/headBg.png") no-repeat;*/
   background-size: 100% auto;
   color: white;
   height: 14%;
   display: flex;
   flex-direction: row;
   align-items: center;
   z-index: 99;
 }
  header h1 a{
    font-size: 30px;
    letter-spacing: 3px;
    text-shadow: 5px 5px 10px black;
    color: white;
    text-decoration: none;
  }
  .center{
    background: white;
    height: 100%;
    overflow-y: scroll;
  }

  /*修改滚动条样式*/
  .center::-webkit-scrollbar{
    width:10px;
    height:10px;
    /**/
  }
  .center::-webkit-scrollbar-track{
    background: rgb(239, 239, 239);
    border-radius:2px;
  }
  .center::-webkit-scrollbar-thumb{
    background: #bfbfbf;
    border-radius:10px;
  }
  .center::-webkit-scrollbar-thumb:hover{
    background: #333;
  }
  .center::-webkit-scrollbar-corner{
    background: #179a16;
  }

</style>
